<?php

class ProductSize extends AppModel {

    var $name = 'ProductSize';
    var $belongsTo = array(
        'Sizetitle' => array(
            'class' => 'Sizetitle',
            'foreignKey' => 'sizetitle_id'
        ),
        'Sizevalue' => array(
            'class' => 'Sizevalue',
            'foreignKey' => 'sizevalue_id'
        ),
        'Sizelabel' => array(
            'class' => 'Sizelabel',
            'foreignKey' => 'sizelabel_id'
        )
    );

    function size_menu() {
        $this->unbindModel(array('belongsTo' => array('Sizetitle', 'Sizelabel')));
        $allsizes = $this->find('all', array('fields' => array('Sizevalue.size_value'), 'order' => 'Sizevalue.id ASC', 'group' => 'Sizevalue.size_value'));
        return $allsizes;
    }

    function size_menu1($id) {
        $this->unbindModel(array('belongsTo' => array('Sizetitle', 'Sizelabel')));
        $allsizes = $this->find('all', array('fields' => array('ProductSize.product_id'), 'conditions' => array('Sizevalue.size_value' => $id)));
        return $allsizes;
    }
}